@echo off
::
:: Configuration variables
::
:: JAVA_HOME
::   Home of Java installation.
::
:: JAVA_OPTIONS
::   Extra options to pass to the JVM
::

:: ----- Verify and Set Required Environment Variables -------------------------

if not "%JAVA_HOME%" == "" goto gotJavaHome
echo You must set JAVA_HOME to point at your Java Development Kit installation
goto end
:gotJavaHome

:: ----- Check System Properties -----------------------------------------------

if not "%JAVA_OPTIONS%" == "" goto gotJavaOptions
set JAVA_OPTIONS=-Xms256M -Xmx1024M
:gotJavaOptions

if not "%JAVA_DEBUG_ARGS%" == "" goto gotJavaDebugArgs
set JAVA_DEBUG_ARGS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
:gotJavaDebugArgs

if not "%JAVA_PROFILE_ARGS%" == "" goto gotJavaProfileArgs
set JAVA_PROFILE_ARGS=-Xrunhprof:heap=all,cpu=samples,thread=y,depth=3
:gotJavaProfileArgs

:: ----- Set Up The Classpath --------------------------------------------------

set CP=.\tools\loader\loader.jar

:: ----- Check action ----------------------------------------------------------

if ""%1"" == ""run"" goto doRun
if ""%1"" == ""debug"" goto doDebug
IF ""%1"" == ""profile"" goto doProfile

echo Usage: longwell (action) (properties-file) [initialization-file-or-dir]
echo actions:
echo   run     Run longwell
echo   debug   Run longwell and turn on remote JVM debug
echo   profile Run longwell and turn on JVM profiling
echo example:
echo   longwell run longwell.properties ./src/rdf
goto end

:: ----- Servlet ---------------------------------------------------------------

:doRun
"%JAVA_HOME%\bin\java.exe" %JAVA_OPTIONS% -classpath "%CP%" -Dorg.xml.sax.parser=org.apache.xerces.parsers.SAXParser -Dloader.jar.repositories=build\eclipse;build\classes;lib -Dloader.main.class=edu.mit.simile.longwell.Main Loader %2 %3
goto end

:: ----- Servlet Debug ---------------------------------------------------------

:doDebug
"%JAVA_HOME%\bin\java.exe" %JAVA_OPTIONS% %JAVA_DEBUG_ARGS% -classpath "%CP%" -Dorg.xml.sax.parser=org.apache.xerces.parsers.SAXParser -Dloader.jar.repositories=build\eclipse;build\classes;lib -Dloader.main.class=edu.mit.simile.longwell.Main Loader %2 %3
goto end

:: ----- Servlet Profile ---------------------------------------------------------

:doProfile
"%JAVA_HOME%\bin\java.exe" %JAVA_OPTIONS% %JAVA_PROFILE_ARGS% -classpath "%CP%" -Dorg.xml.sax.parser=org.apache.xerces.parsers.SAXParser -Dloader.jar.repositories=build\eclipse;build\classes;lib -Dloader.main.class=edu.mit.simile.longwell.Main Loader %2 %3

:: ----- End -------------------------------------------------------------------

:end
set CP=

